﻿using Shapes.AbstractClassess;
using Shapes.ConcreteClasses;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Shapes
{
    class Program
    {
        private static List<Shape> shapes;
        static void Main(string[] args)
        {
            shapes = new List<Shape>();

            string input = string.Empty;
            while (input != "exit")
            {
                W("Type the word exit to quit");
                W("1. Calculate Area of a Triangle");
                W("2. Calculate Area of a Circle");
                W("3. Calculate Area of a Rectangle");
                W("4. Display number of shapes I've made");

                input = Console.ReadLine().ToLower();

                switch(input)
                {
                    case "1":
                        DoTriangleArea();
                        break;
                    case "2":
                        DoCircleArea();
                        break;
                    case "3":
                        DoRectangleArea();
                        break;
                    case "4":
                        DoNumberOfShapesMade();
                        break;
                }
            }
        }

        private static void DoNumberOfShapesMade()
        {
            int numberOfShapes = shapes.Count;
            W("You've created " + numberOfShapes + " shapes.");
        }

        private static void CalcAndDisplayArea(Shape s)
        {
            shapes.Add(s);
            double area = s.Area();

            W("The area of the " + s.GetType().Name + " is: " + area);
        }

        private static void DoRectangleArea()
        {
            W("Enter the Length of the Rectangle");
            string lengthString = Console.ReadLine();

            W("Enter the Width of the Rectangle");
            string widthString = Console.ReadLine();

            Rectangle r = new Rectangle();
            r.Length = double.Parse(lengthString);
            r.Width = double.Parse(widthString);
            //double area = r.Area();

            //W("The area of the Rectangle is: " + area);

            CalcAndDisplayArea(r);
        }

        private static void DoCircleArea()
        {
            W("Enter the Radius of the Circle");
            string radiusString = Console.ReadLine();

            Circle c = new Circle();
            c.Radius = double.Parse(radiusString);
            //double area = c.Area();

            //W("The area of the Circle is: " + area);

            CalcAndDisplayArea(c);
        }

        private static void DoTriangleArea()
        {
            W("Enter the Base of the Triangle");
            string baseString = Console.ReadLine();
            W("Enter the Height of the Triangle");
            string heightString = Console.ReadLine();

            Triangle t = new Triangle();
            t.Base = double.Parse(baseString);
            t.Height = Convert.ToDouble(heightString);
            //double area = t.Area();

            //W("The Area of the Triangle is: " + area);
            CalcAndDisplayArea(t);
        }


        public static void W(string text)
        {
            Console.WriteLine(text);
        }
    }
}
